const BASE_URL = "https://lh.pluss.top/api"
// const BASE_URL = "http://81.70.168.242"

/**
 * 通用请求
 * @param {String} url 链接
 * @param {String} 请求方式 
 * @param {any} 数据 
 * @returns 
 */
// TODO
export const request = ({
	url,
	method,
	header,
	data
}) => {


	/* const defaultHeader = {
		'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
	}
	console.log(arguments[0])
	Object.prototype.hasOwnProperty.call(arguments[0],'header') && Object.assign(header,defaultHeader) */

	return new Promise((resolve, reject) => {
		uni.request({
			url: `${BASE_URL}${url}`,
			header,
			method,
			data, // 取用户id就是这样:{...data,userId:uni.getStorageSync('userInfo').userid}
			success: (res) => { resolve(res.data) },
			fail: reject
		})
	})
}
